<?php
namespace app\admin\controller\general;

use app\common\controller\Backend;
use think\Config;
use think\Validate;

/**
 * Database_Backup
 *
 * @icon  fa fa-database
 */
class Data extends Backend
{
    public function index()
    {
        $this->request->filter(['strip_tags', 'trim']);
        if ($this->request->isAjax()) {
            $path = ROOT_PATH."public/data/*";
            $fileList = glob($path);
            $sqlData = [];
            foreach ($fileList as $oneFile){
                $temp = [
                    'name'=>basename($oneFile),
                    'create_time'=>date("Y-m-d H:i:s",filectime($oneFile)),
                    'file_size'=>filesize($oneFile),
                    'url'=>str_replace(ROOT_PATH.'public',request()->domain(),$oneFile),
                ];
                $sqlData[] = $temp;
            }

            $result = array("total" => count($sqlData), "rows" => $sqlData,"extend"=>[]);
            return json($result);
        }
        return $this->view->fetch();
    }
}
